<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Conexion
 *
 * @author User
 */
class Conexion {

    private $hostname = "localhost";
    private $database = "plazadb";
    private $username = "root";
    private $password = "";
    private $session = null;

    function __construct() {
        
    }

    public function open() {
        try {
            if (!isset($this->session)) {
                $this->session = @mysql_connect($this->hostname, $this->username, $this->password);
            }
            if (isset($this->session)) {
                @mysql_select_db($this->database, $this->session);
            }
        } catch (Exception $e) {
            
        }
    }

    public function query($query) {
        $result = null;
        try {
            if (isset($this->session)) {
                $result = @mysql_query($query, $this->session);
            }
        } catch (Exception $e) {
            
        }
        return $result;
    }

    public function close() {
        try {
            if (isset($this->session)) {
                @mysql_close($this->session);
                $this->session = null;
            }
        } catch (Exception $e) {
            $this->session = null;
        }
    }

}

?>
